import React, { JSX } from 'react';
import { Navigate } from 'react-router-dom';
import useAuth from '@/hooks/useAuth';

interface ProtectedRouteProps {
  Comp: JSX.Element;
}

const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ Comp }) => {
  const isAuthenticated = useAuth();

  if (!isAuthenticated) {
    return <Navigate to="/login" />;
  }

  return Comp;
};

export default ProtectedRoute;